package com.example.user.service.impl;

import com.example.user.dao.UserMapper;
import com.example.user.pojo.User;
import com.example.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @BelongsProject: fourperiodtest
 * @BelongsPackage: com.example.user.service.impl
 * @Author: 江岸
 * @CreateTime: 2020-06-30 10:30
 * @Description:
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public String register(User user) {
        System.out.println(user);
        int i = userMapper.checkName(user);
        if(i>0){
            return "The user name already exists";
        }
        int registere = userMapper.registere(user);
        if(registere>0){
            return "register success";
        }
        return "register failed";
    }

    @Override
    public String login(User user) {
        int login = userMapper.login(user);
        if(login>0){
            return "login success";
        }
        return "login failed";
    }
}
